package  
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.utils.getTimer;
	
	/**
	 * ...
	 * @author Argus
	 */
	public class TestContainer extends Sprite 
	{
		public var id:String;
		private var _sp:Sprite;
		public function TestContainer() 
		{
			this.graphics.beginFill(Math.random() * 0xffffff, 1);
			this.graphics.drawRect(0, 0, 100, 100);
			this.graphics.endFill();
			this.addEventListener(Event.ADDED_TO_STAGE, handleThisAddedToStage);
			this.addEventListener(Event.REMOVED_FROM_STAGE, handleThisRemovedFromStage);
			/*this.addEventListener(Event.RENDER, handleThisRender);
			this.addEventListener(Event.CHANGE, handleThisChange);*/
		}
		
		private function handleThisRemovedFromStage(e:Event):void 
		{
			//removeEventListener(Event.REMOVED_FROM_STAGE, handleThisRemovedFromStage);
			this.parent.addEventListener(Event.RESIZE, handleParentChange);
		}
		
		private function handleParentChange(e:Event):void 
		{
			trace("parent change");
		}
		
		override public function set scaleX(value:Number):void
		{
			super.scaleX = value;
			trace("scaleX",this,this.id);
		}
		
		override public function set scaleY(value:Number):void
		{
			super.scaleY = value;
			trace("scaleX",this,this.id);
		}
		
		private function handleThisChange(e:Event):void 
		{
			trace("change:",this,this.id)
		}
		
		private function handleThisRender(e:Event):void 
		{
			trace("render:", this, this.id,this.width,this.height);
		}
		
		override public function set y(value:Number):void
		{
			super.y = value;
			this.graphics.clear();
			this.graphics.beginFill(0xff0000, 1);
			this.graphics.drawCircle(0, 0, 100);
			this.graphics.endFill();
		}
		
		private function handleThisAddedToStage(e:Event):void 
		{
			//removeEventListener(Event.ADDED_TO_STAGE, handleThisAddedToStage);
			trace("addToStage:", this, this.id, this.width, this.height);
			_sp = new Sprite();
			
			this.addEventListener(MouseEvent.CLICK, handleThisClick);
			//stage.addEventListener(Event.RESIZE, handleStageResize);
		}
		
		private function handleThisClick(e:MouseEvent):void 
		{
			
		}
		
		private function handleStageResize(e:Event):void 
		{
			
		}
		
		private function handleStageRender(e:Event):void 
		{
			
		}
		
	}

}